﻿using www.w3.org.Item2001.XMLSchema;

namespace Sidvall.CodeGenerator.DataObjects
{
	public class Schema
	{
		#region Business Members

		public SchemaElementCollection Elements { get; private set; }
		public SchemaAttributeCollection Attributes { get; private set; }
		public SchemaComplexTypeCollection ComplexTypes { get; private set; }
		public SchemaSimpleTypeCollection SimpleTypes { get; private set; }
		public SchemaIncludeCollection Includes { get; private set; }
		public SchemaImportCollection Imports { get; private set; }

		#region Import

		public void Import(schema item, string fileName)
		{
			if (item == null)
				return;

			foreach (var o in item.element)
				this.Elements.Add(item, o, fileName);
			foreach (var o in item.attribute)
				this.Attributes.Add(item, o, fileName);
			foreach (var o in item.complexType)
				this.ComplexTypes.Add(item, o, fileName);
			foreach (var o in item.simpleType)
				this.SimpleTypes.Add(item, o, fileName);
			foreach (var o in item.include)
				this.Includes.Add(item, o, fileName);
			foreach (var o in item.import)
				this.Imports.Add(item, o, fileName);
		}

		#endregion

		#endregion
		#region Constructors

		public Schema()
		{
			this.Elements = new SchemaElementCollection();
			this.Attributes = new SchemaAttributeCollection();
			this.ComplexTypes = new SchemaComplexTypeCollection();
			this.SimpleTypes = new SchemaSimpleTypeCollection();
			this.Includes = new SchemaIncludeCollection();
			this.Imports = new SchemaImportCollection();
		}

		#endregion
	}
}
